let Promise = require('./promise1');
let fs = require('fs');
let p = new Promise((resolve,reject)=>{ //=>executor 执行器
  //pendding 等待
  console.log('会执行')
  throw new Error('try catch 错误');
  fs.readFile('./name.txt','utf-8',function(err,data){
    if(err){
     return  reject(err);
    }
    resolve(data);
  })
})
// 每个promise 实例上都有then 方法
console.log('hello');
p.then((value)=>{
  console.log('成功')
},(reason)=>{
  console.log('失败')
}).catch((error)=>{
  console.log(error);
})